<?php
session_start();
if(!isset($_SESSION['uid']))
 	{?>
		<script type="text/javascript">
			window.location="error.php";
		</script>
	<?php
 	}else
 		{
 			include_once 'topStaticBar.php';
 			include_once 'dataBaseConnectivityFile.php';
			$sql_get=mysql_query("select * from stock where STOCK_ID=".$_REQUEST['stock_id']);
 			if (!$sql_get)
 			{
    			echo 'Could not run query: '.mysql_error();
			}

			while ($db_field=mysql_fetch_assoc($sql_get))
                {
                	$STOCK_ID=$db_field["STOCK_ID"];
                	$TITLE=$db_field["TITLE"];
                    $CONDITION=$db_field["CONDITION"];                    
                    $MAKE=$db_field["MAKE"];
                    $BODY_STYLE=$db_field["BODY_STYLE"];
                    $START_YEAR=$db_field["START_YEAR"];
					$END_YEAR=$db_field["END_YEAR"];
					$MILEAGE=$db_field["MILEAGE"];
					$TRANSMISSION=$db_field["TRANSMISSION"];
					$DRIVE_TRAIN=$db_field["DRIVE_TRAIN"];
					$EXTERIOR_COLOR=$db_field["EXTERIOR_COLOR"];
					$INTERIOR_COLOR=$db_field["INTERIOR_COLOR"];
					$FUEL_TYPE=$db_field["FUEL_TYPE"];
					$CITY_MILES_PER_GALLON=$db_field["CITY_MILES_PER_GALLON"];
					$HIGHWAY_MILES_PER_GALLON=$db_field["HIGHWAY_MILES_PER_GALLON"];            
                    $get_status=$db_field["STATUS"];
                    $PRICE=$db_field["PRICE"];
                    $CONTACT_NO=$db_field["CONTACT_NO"];
					$MODEL_NUMBER=$db_field["MODEL_NUMBER"];
					$ENGINE=$db_field["ENGINE"];
					$VIN=$db_field["VIN"];                    
                }

 		?>	
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<h1 align="center">Edit Basic Information</h1>
	<form name="form" method="post" action="editBasicInformationServer.php">
		<input type="hidden" name="stock_id" value="<?php echo $_REQUEST['stock_id']?>">
		<table border="0" align="center">
		<tr>
			<td align="right">
				Title:
			</td>
			<td>
				<input type="text" name="title" value="<?php echo $TITLE?>" style="width: 600px">
			</td>
		</tr>

		<tr>
			<td align="right">
				Engine:
			</td>
			<td>
				<input type="text" name="engine" value="<?php echo $ENGINE?>" style="width: 300px">
			</td>
		</tr>		

		<tr>
			<td align="right">
				Model Number:
			</td>
			<td>
				<input type="text" name="model_number" value="<?php echo $MODEL_NUMBER?>" style="width: 300px">
			</td>
		</tr>				

		<tr>
		<td align="right">
			VIN#: 
		</td>
		<td align="left">
			<input type="text" name="vin" style="width: 200px" value="<?php echo $VIN?>">
		</td>
		</tr>		
			<tr>
				<td align="right">
					Condition:
				</td>
				<td align="left">
					<select name="condition">
						<option value="<?php echo $CONDITION?>"><?php echo $CONDITION?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (`CONDITION`) from filters where `CONDITION` is not NULL and `CONDITION` !=	'".$CONDITION."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$CONDITION_fromDB2=$db_field2["CONDITION"];
						?>						
						<option value="<?php echo $CONDITION_fromDB2 ?>"><?php echo $CONDITION_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Condition</option>
 					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					Make:
				</td>
				<td align="left">
					<select name="make">
						<option value="<?php echo $MAKE?>"><?php echo $MAKE?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (MAKE) from filters where MAKE is not NULL and MAKE !=	'".$MAKE."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$MAKE_fromDB2=$db_field2["MAKE"];
						?>						
						<option value="<?php echo $MAKE_fromDB2 ?>"><?php echo $MAKE_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Make</option>
 					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					Body Style:
				</td>
				<td align="left">
					<select name="body_style">
						<option value="<?php echo $BODY_STYLE?>"><?php echo $BODY_STYLE?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (BODY_STYLE) from filters where BODY_STYLE is not NULL and BODY_STYLE !=	'".$BODY_STYLE."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$BODY_STYLE_fromDB2=$db_field2["BODY_STYLE"];
						?>						
						<option value="<?php echo $BODY_STYLE_fromDB2 ?>"><?php echo $BODY_STYLE_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Body Style</option>
 					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					Start Year:
				</td>
				<td align="left">
					<select name="start_year">
					<option value="<?php echo $START_YEAR ?>"><?php echo $START_YEAR ?></option>					
					<option value="">Select Start Year</option>
					<option value="1990">1990</option>
					<option value="1991">1991</option>
					<option value="1992">1992</option>
					<option value="1993">1993</option>
					<option value="1994">1994</option>
					<option value="1995">1995</option>
					<option value="1996">1996</option>
					<option value="1997">1997</option>
					<option value="1998">1998</option>
					<option value="1999">1999</option>
					<option value="2000">2000</option>
					<option value="2001">2001</option>
					<option value="2002">2002</option>
					<option value="2003">2003</option>
					<option value="2004">2004</option>
					<option value="2005">2005</option>
					<option value="2006">2006</option>
					<option value="2007">2007</option>
					<option value="2008">2008</option>
					<option value="2009">2009</option>
					<option value="2010">2010</option>
					<option value="2011">2011</option>
					<option value="2012">2012</option>
					<option value="2013">2013</option>
					<option value="2014">2014</option>
					<option value="2015">2015</option>
					<option value="2016">2016</option>
					<option value="2017">2017</option>
					<option value="2018">2018</option>
					<option value="2019">2019</option>
					<option value="2020">2020</option>					
					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					End Year:
				</td>
				<td align="left">
					<select name="end_year">
					<option value="<?php echo $END_YEAR?>"><?php echo $END_YEAR?></option>
					<option value="">Select End Year </option>
					<option value="1990">1990</option>
					<option value="1991">1991</option>
					<option value="1992">1992</option>
					<option value="1993">1993</option>
					<option value="1994">1994</option>
					<option value="1995">1995</option>
					<option value="1996">1996</option>
					<option value="1997">1997</option>
					<option value="1998">1998</option>
					<option value="1999">1999</option>
					<option value="2000">2000</option>
					<option value="2001">2001</option>
					<option value="2002">2002</option>
					<option value="2003">2003</option>
					<option value="2004">2004</option>
					<option value="2005">2005</option>
					<option value="2006">2006</option>
					<option value="2007">2007</option>
					<option value="2008">2008</option>
					<option value="2009">2009</option>
					<option value="2010">2010</option>
					<option value="2011">2011</option>
					<option value="2012">2012</option>
					<option value="2013">2013</option>
					<option value="2014">2014</option>
					<option value="2015">2015</option>
					<option value="2016">2016</option>
					<option value="2017">2017</option>
					<option value="2018">2018</option>
					<option value="2019">2019</option>
					<option value="2020">2020</option>
					</select>
				</td>
			</tr>

			<tr align="right">
				<td>
					Odometer <span style="color: red">(Only Enter Digits)</span>:
				</td>
				<td align="left">
					<input type="text" name="mileage" value="<?php echo $MILEAGE?>">					
				</td>
			</tr>
			<tr align="right">
				<td>
					Transmission:
				</td>
				<td align="left">
					<select name="transmission">
						<option value="<?php echo $TRANSMISSION?>"><?php echo $TRANSMISSION?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (TRANSMISSION) from filters where TRANSMISSION is not NULL and TRANSMISSION !=	'".$TRANSMISSION."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$TRANSMISSION_fromDB2=$db_field2["TRANSMISSION"];
						?>						
						<option value="<?php echo $TRANSMISSION_fromDB2 ?>"><?php echo $TRANSMISSION_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Transmission</option>
 					</select>
				</td>
			</tr>	
			<tr align="right">
				<td>
					DriveTrain:
				</td>
				<td align="left">
					<select name="drivetrain">
						<option value="<?php echo $DRIVE_TRAIN?>"><?php echo $DRIVE_TRAIN?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (DRIVE_TRAIN) from filters where DRIVE_TRAIN is not NULL and DRIVE_TRAIN !=	'".$DRIVE_TRAIN."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$DRIVE_TRAIN_fromDB2=$db_field2["DRIVE_TRAIN"];
						?>						
						<option value="<?php echo $DRIVE_TRAIN_fromDB2 ?>"><?php echo $DRIVE_TRAIN_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Drive Train</option>
 					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					Exterior Color:
				</td>
				<td align="left">
					<select name="exterior_color">
						<option style="background-color: <?php echo $EXTERIOR_COLOR ?>" value="<?php echo $EXTERIOR_COLOR?>"><?php echo $EXTERIOR_COLOR?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (EXTERIOR_COLOR) from filters where EXTERIOR_COLOR is not NULL and EXTERIOR_COLOR !=	'".$EXTERIOR_COLOR."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$EXTERIOR_COLOR_fromDB2=$db_field2["EXTERIOR_COLOR"];
						?>						
						<option style="background-color: <?php echo $EXTERIOR_COLOR_fromDB2 ?>" value="<?php echo $EXTERIOR_COLOR_fromDB2 ?>"><?php echo $EXTERIOR_COLOR_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Exterior Color</option>
 					</select>
				</td>
			</tr>			
			<tr align="right">
				<td>
					Interior Color:
				</td>				
				<td align="left">
					<select name="interior_color">
						<option style="background-color: <?php echo $INTERIOR_COLOR ?>" value="<?php echo $INTERIOR_COLOR?>"><?php echo $INTERIOR_COLOR?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (INTERIOR_COLOR) from filters where INTERIOR_COLOR is not NULL and INTERIOR_COLOR !=	'".$INTERIOR_COLOR."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$INTERIOR_COLOR_fromDB2=$db_field2["INTERIOR_COLOR"];
						?>						
						<option style="background-color: <?php echo $INTERIOR_COLOR_fromDB2 ?>" value="<?php echo $INTERIOR_COLOR_fromDB2 ?>"><?php echo $INTERIOR_COLOR_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Interior Color</option>
 					</select>
				</td>
				</tr>
			<tr align="right">
				<td>
					Fuel Type:
				</td>
					<td align="left">
					<select name="fuel_type">
						<option value="<?php echo $FUEL_TYPE?>"><?php echo $FUEL_TYPE?></option>
				<?php
			 			include_once 'topStaticBar.php';
			 			include_once 'dataBaseConnectivityFile.php';
						$sql_get=mysql_query("select (FUEL_TYPE) from filters where FUEL_TYPE is not NULL and FUEL_TYPE !=	'".$FUEL_TYPE."'	");
			 			if (!$sql_get)
			 			{
			    			echo 'Could not run query: '.mysql_error();
						}while($db_field2=mysql_fetch_assoc($sql_get))
						{
							$FUEL_TYPE_fromDB2=$db_field2["FUEL_TYPE"];
						?>						
						<option value="<?php echo $FUEL_TYPE_fromDB2 ?>"><?php echo $FUEL_TYPE_fromDB2?></option>
					<?php
 						}
 					?>
	 				<option value="">Select Fuel Type</option>
 					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					City Miles/Gallon:
				</td>
				<td align="left">
					<input type="text" name="city_miles" value="<?php echo $CITY_MILES_PER_GALLON ?>">
				</td>
			</tr>
			<tr align="right">
				<td>
					Highway Miles/Gallon:
				</td>
				<td align="left">
					<input name="highway_miles" type="text" value="<?php echo $HIGHWAY_MILES_PER_GALLON?>">
				</td>
			</tr>
			<tr align="right">
				<td>
					Status:
				</td>
				<td align="left">
					<select name="status">
						<option value="<?php echo $get_status?>"><?php echo $get_status?></option> 
						<option value="">Select Status</option>
						<option value="Sold">Sold</option>
						<option value="For-Sale">For-Sale</option>
						<option value="Sale Pending">Sale Pending</option>
					</select>
				</td>
			</tr>
			<tr align="right">
				<td>
					PRICE($):
				</td>
				<td align="left">
					<input type="text" name="PRICE" value="<?php echo $PRICE?>">
				</td>
			</tr>						
			<tr align="right">
				<td>
					Contact#:
				</td>
				<td align="left">
					<input type="text" name="contact" value="<?php echo $CONTACT_NO?>">
				</td>
			</tr>			
		</table>
		
		<table border="0" align="center">
			<tr align="center">
				<td align="center">
					<input type="submit" name="save_basic_profile" id="send" value="Save Car Info">
				</td>
			</tr>			
		</table>
	</form> 			
 	<?php	
 		}
 		?>